package com.zhiche.lisa.mdm.controller.inner;


import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import com.zhiche.lisa.mdm.dao.model.FleetType;
import com.zhiche.lisa.mdm.service.IFleetTypeService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 车队类型 前端控制器
 * </p>
 *
 * @author qichao
 * @since 2018-08-28
 */
@RestController
@RequestMapping("/inner/fleetType")
public class FleetTypeController {
    private final static Logger LOGGER = LoggerFactory.getLogger(FleetTypeController.class);
    @Autowired
    private IFleetTypeService iFleetTypeService;

    @GetMapping(value = "/getAllFleetTypeByType")
    @ApiOperation(value = "根据类型Id获取车队类型", notes = "根据类型Id获取车队类型", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    public RestfulResponse<List<FleetType>> getAllFleetTypeByType() {
        RestfulResponse<List<FleetType>> result = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            result.setData(iFleetTypeService.getAllFleetTypeByType());
        } catch (BaseException e) {
            LOGGER.error("FleetTypeController.getAllFleetTypeByType ERROR... ", e);
            result = new RestfulResponse<>(e.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("FleetTypeController.getAllFleetTypeByType ERROR... ", e);
            result = new RestfulResponse<>(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return result;
    }

}

